Skip to content

Making--libraries#25

Open
Butcher3Years wants to merge 26 commits intomainfrom
making--libraries
Open

Making--libraries#25
Butcher3Years wants to merge 26 commits intomainfrom
making--libraries

Conversation

@Butcher3Years
Copy link
Copy Markdown
Owner

Making & Working with Libraries in C++ – Cherno-Style (Headers, Linking, Static vs Dynamic) 🪓🔥

Branch: making-libraries
From The Cherno's C++ series — the episodes where he screams about "linker hell", missing symbols, DLL nightmares, and why build systems are both evil and necessary.

What "Making a Library" Actually Means

A library is just your code that you want to reuse in multiple projects (or share with others) without copy-pasting everything.

Two main types:

Type File Extensions (Windows) Baked into exe? Update lib without recompiling? Best For
Static Library .lib / .a Yes No Standalone apps, games, no missing files
Dynamic Library .dll / .so / .dylib No Yes Plugins, shared code, engine + game separation

Cherno:

"Static is simple and safe — everything in one exe.
Dynamic is powerful but brings DLL hell. Choose wisely or suffer."

Step-by-Step – How Cherno Teaches Making & Using Libraries

1. Making a Static Library (Engine as .lib)

Create your "Engine" project → build as static lib (.lib)

// Engine.h (header)
#pragma once

void Log(const std::string& msg);
int Add(int a, int b);


// Engine.cpp (implementation)
#include "Engine.h"
#include <iostream>

void Log(const std::string& msg) {
    std::cout << "[ENGINE] " << msg << "\n";
}

int Add(int a, int b) { return a + b; }


…] differs,and exploring types of strings based on sizes and their writting style
…lso for the performance of not creating other non wanted object

classes
and types of allocating class objects
and when to use them!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant